<div class="full-screen">
    <header class="bg-red">
    <div class="a-bar">
        <a href="javascript:history.back()" class="a-back">
            <i class="arr left"></i>
            返回
        </a>
        <div class="a-name">
            我的订单
        </div>
    </div>
    </header>
    <div>
    <center>
    <div style="width: 100%;height: 35px;line-height: 35px;background: #f1f2f3;">
    <div style="margin:auto;width: 90%;">
    
    <a class= "icon <{if $pay_status=='all'}>act<{/if}>" style="float: left;width: 18%;height: 30px;font-size: 12px;margin-left: 5%;
    line-height: 35px;"
    href="<{link app=b2c ctl=wap_member act=orders arg0=all}>">全部</a>    &nbsp;   

    <a class= "icon <{if $pay_status=='nopayed'}>act<{/if}>" style="float: left;width: 15%;height: 30px;font-size: 12px;margin-left: 2%;
    line-height: 35px;" href="<{link app=b2c ctl=wap_member act=orders arg0=nopayed}>">未付款</a>    &nbsp;

    <a class= "icon <{if $pay_status=='noship'}>act<{/if}>" style="float: left;width: 15%;height: 30px;font-size: 12px;margin-left: 2%;
    line-height: 35px;" href="<{link app=b2c ctl=wap_member act=orders arg0=noship}>">未发货</a> &nbsp; 

    <a class= "icon <{if $pay_status=='noreceived'}>act<{/if}>" style="float: left;width: 15%;height: 30px;font-size: 12px;margin-left: 2%;
    line-height: 35px;" href="<{link app=b2c ctl=wap_member act=orders arg0=noreceived}>">未收货</a> &nbsp;  

    <a class= "icon <{if $pay_status=='dead'}>act<{/if}>" style="float: left;width: 15%;height: 30px;font-size: 12px;margin-left: 2%;
    line-height: 35px;" href="<{link app=b2c ctl=wap_member act=orders arg0=dead}>">已取消</a>

    </div >
    </div>
    </center>
    </div>
    <div class="full-padding">
        <ul class="mem-order-list">
            <{foreach from=$orders item="order" name=orders key="key"}>
            <li class="mem-order-item">
                <div class="icon orange">
                    <{switch from=$order.status}>
                    <{case value='finish'}><{t}>已完成<{/t}>
                    <{case value='dead'}><{t}>已作废<{/t}>
                    
                    <{case}>
                    <{switch from=$order.pay_status}>
                    <{case value='1'}><{t}>已付款<{/t}>
                    <{switch from=$order.ship_status}>
                    <{case value='1'}><{t}>[已发货]<{/t}>
            <{switch from=$order.received_status}><!--add by wenlong-->
                <{case value='1'}><{t}>[已收货]<{/t}><!--add by wenlong-->
                <{/switch}><!--add by wenlong-->
                    <{case value='2'}><{t}>[部分发货]<{/t}>
                    <{switch from=$order.received_status}>
                    <{case value='2'}><{t}>[部分收货]<{/t}>
                    <{/switch}>
                    <!--add by 文龙 2017 03 30-->
                    <{case value='3'}><{t}>[部分退货]<{/t}>
                    <{case value='4'}><{t}>[已退货]<{/t}>
                    <{case}><{t}>[正在备货]<{/t}>
                    <{/switch}>
                    <{case value='2'}><{t}>已付款至担保方<{/t}>
                    <{case value='3'}><{t}>等待补款<{/t}>
                    <{switch from=$order.ship_status}>
                    <{case value='1'}><{t}>[已发货]<{/t}>
                    <{case value='2'}><{t}>[部分发货]<{/t}>
                    <{case value='3'}><{t}>[部分退货]<{/t}>
                    <{case value='4'}><{t}>[已退货]<{/t}>
                    <{/switch}>
                    <{case value='4'}><{t}>部分退款<{/t}>
                    <{switch from=$order.ship_status}>
                    <{case value='0'}><{t}>[未发货]<{/t}>
                    <{case value='1'}><{t}>[已发货]<{/t}>
                    <{case value='2'}><{t}>[部分发货]<{/t}>
                    <{case value='3'}><{t}>[部分退货]<{/t}>
                    <{case value='4'}><{t}>[已退货]<{/t}>
                    <{/switch}>
                    <{case value='5'}><{t}>已退款<{/t}>
                    <{switch from=$order.ship_status}>
                    <{case value='0'}><{t}>[未发货]<{/t}>
                    <{case value='1'}><{t}>[已发货]<{/t}>
                    <{case value='2'}><{t}>[部分发货]<{/t}>
                    <{case value='3'}><{t}>[部分退货]<{/t}>
                    <{case value='4'}><{t}>[已退货]<{/t}>
                    <{/switch}>
                    <{case}><{t}><{if $order.payinfo.pay_app_id == 'offline'}><{if $order.ship_status == 0}>等待发货<{/if}><{else}>等待付款<{/if}><{/t}>
                    <{switch from=$order.ship_status}>
                    <{case value='1'}><{t}>[已发货]<{/t}>
            <{switch from=$order.received_status}><!--add by wenlong-->
                <{case value='1'}><{t}>[已收货]<{/t}><!--add by wenlong-->
                <{/switch}><!--add by wenlong-->
                    <{case value='2'}><{t}>[部分发货]<{/t}>
            <{switch from=$order.received_status}>
                    <{case value='2'}><{t}>[部分收货]<{/t}>
                    <{/switch}>
                    <{case value='3'}><{t}>[部分退货]<{/t}>
                    <{case value='4'}><{t}>[已退货]<{/t}>
                    <{/switch}>
                    <{/switch}>
                    <{/switch}>
                </div>
                <div class="gb">
                    <div class="col2">
                        <div class="col">
                            <div class="d-line" style="display:none;">
                                <div class="l-k">订单号：</div>
                                <div class="l-v"><{$order.order_id}></div>
                            </div>
                            <!--<div class="d-line">-->
                                <!--<div class="l-k">共<{$quantity}>件商品</div>-->
                                <!--<div class="l-v">-->
                                    <!--<span class="price"></span>-->
                                <!--</div>-->
                            <!--</div>-->
                            <div class="d-line">
                                <div class="l-k">应付金额：</div>
                                <div class="l-v">
                                    <span class="price"><{$order.cur_amount|cur_odr:$order.currency:false:true}></span>
                                </div>
                            </div>
                            <div class="d-line" style="display:none;">
                                <div class="l-k">支付方式：</div>
                                <div class="l-v">
                                    <{$order.payinfo.pay_app_id|pay_name}>
                                </div>
                            </div>
                            <div class="d-line">
                                <div class="l-k">订单时间：</div>
                                <div class="l-v">
                                    <{$order.createtime|cdate:FDATE_STIME}>
                                </div>
                            </div>
                        </div>
                    </div>
                        <div class="col d-line" style="   ">
                            <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;    margin-left: .4rem;">
                                <{if $order.status == 'active' && ($order.pay_status=='0' || $order.pay_status=='3') && $order.payinfo.pay_app_id != 'offline'}>
                                <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==0 }>
                                <a href="<{link app=b2c ctl=wap_paycenter act=index arg0=$order.order_id}>"  style="color:#fff;">
                                    去付款
                                    <!-- <i class="arr right"></i> -->
                                </a>
                                <{/if}>
                                <{if $order.payinfo.pay_app_id != '-1' && $order.is_pay==1 }>
                                <a href="javascript:void(0);" onclick="js_method()" style="color:#ccc;">
                                    支付结果返回中
                                    <!-- <i class="arr right"></i> -->
                                </a>
                                <{/if}>
                                <{/if}>
                            </div>
                            <{if $order.status != 'dead' && $order.ship_status =="1" && ($order.received_status =='0' || $order.received_status == '2') && $order.ship_receive_status == 'ship'}>
                                <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;">
                                    <a href="javascript:void(0);" onclick="return receive('<{$order.url}>')" style="color:#fff;">确认收货<!-- <i class="arr right"></i> --></a>
                                </div>
                            <{/if}>
                            <{if $order.status != 'dead' && $order.ship_status =="2" && ($order.received_status =='0' || $order.received_status == '2') && $order.ship_receive_status == 'ship'}>
                                <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;">
                                    <a href="javascript:void(0);" onclick="return receive('<{$order.url2}>')" style="color:#fff;">确认部分收货<!-- <i class="arr right"></i> --></a>
                                </div>
                            <{/if}>
                <!--receive a part of products-->
                            <!--add by 文龙 2017 03 30-->
                            <{if $order.status != 'dead' && $order.ship_status =="2" && $order.received_status == '2' && $order.ship_receive_status=='receive'}>
                                <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;">
                                    <a style="color:#999;cursor:default;" href="javascript:void(0);" style="color:#fff;">确认收货<!-- <i class="arr right"></i> --></a>
                                </div>
                            <{/if}>
                            <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;">
                                <a href="<{link app=b2c ctl="wap_member" act="orderdetail" arg0=$order.order_id}>" style="color:#fff;">
                                    查看订单
                                    <!-- <i class="arr right"></i> -->
                                </a>
                            </div>
                            <{if $order.status == 'active' && $order.pay_status == '0' && $order.ship_status == '0' &&  $order.is_pay==0 && $order.payinfo.pay_app_id != 'offline'}>
                            <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;">
                                <a style="color:#fff;" href="<{link app=b2c ctl="wap_member" act="cancel" arg0=$order.order_id}>" >
                                   取消订单
                                    <i class="arr right"></i> 
                                </a>
                            </div>
                            <{/if}>
                            <{if $order.status == 'dead'}>
                                <div class="t-r" style="display:inline-block;background:#ff5800;margin-right:8px;padding:2px;">
                                   <a href="javascript:;" style="color:#fff;"   onclick="delete_product()"><{t}>删除订单<{/t}></a>
                                </div>
                            <{/if}>
                        </div>
                </div>
                <ul class="mem-order-pt c-fix">
                    <!-- goods -->

                    <!-- 一条订单里的全部商品数量 heng -->
                    <!-- <{$quantity = 0}> -->
                    <{foreach from=$order.goods_items item=item_goods name=goods_item}>
                    <!-- <{$quantity += $item_goods.product.quantity}> -->
                    <{/foreach}>
                    <{if $order.goods_items}>
                        <{foreach from=$order.goods_items item=item_goods name=goods_item}>
                            <!-- goods -->
                            <{if $item_goods.product}>
                            <li class="mem-pt-item">
                                <a href='<{$item_goods.product.link_url}>' title="<{$item_goods.product.quantity}>--<{$item_goods.product.name}>">
                                <img src='<{$item_goods.product.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>' />
                                </a>
                                <i class="num"><{$quantity}></i>
                            </li>
                            <{/if}>
                            <!-- adjunct -->
                            <{if $item_goods.adjunct_items}>
                                <{foreach from=$item_goods.adjunct_items item=item_adjunct name=adjunct_item}>
                                <li class="mem-pt-item">
                                    <a href='<{$item_adjunct.link_url}>' title="<{$item_adjunct.quantity}>--<{$item_adjunct.name}>--配件">
                                    <img src="<{$item_adjunct.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>"/>
                                    </a>
                                    <i class="num"><{$item_adjunct.quantity}></i>
                                    <i class="icon red">配件</i>
                                </li>
                                <{/foreach}>
                            <{/if}>
                            <!-- gift -->
                            <{if $item_goods.gift_items}>
                                <{foreach from=$item_goods.gift_items item=item_gift name=gift_item}>
                                <li class="mem-pt-item">
                                  <a href='<{$item_gift.link_url}>' title="<{$item_gift.quantity}>-- <{$item_gift.name}>--赠品">
                                    <img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>"/>
                                    </a>
                                    <i class="num"><{$item_gift.quantity}></i>
                                    <i class="icon red">赠品</i>
                                </li>
                                <{/foreach}>
                            <{/if}>
                        <{/foreach}>
                    <{/if}>

                    <!-- gift -->
                    <{if $order.gift_items}>
                        <{foreach from=$order.gift_items item=item_gift name=gift_item}>
                        <li class="mem-pt-item">
                            <a href='<{$item_gift.link_url}>' title="<{$item_gift.quantity}>--<{$item_gift.name}>--赠">
                            <img src="<{$item_gift.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>"/>
                            </a>
                            <i class="num"><{$item_gift.quantity}></i>
                            <i class="icon red">赠品</i>
                         </li>
                        <{/foreach}>
                    <{/if}>

                    <!-- extends -->
                    <{if $order.extends_items}>
                        <{foreach from=$order.extends_items item=item_extends name=item_extends}>
                            <{$item_extends}>
                        <{/foreach}>
                    <{/if}>
                </ul>


            </li>
            <{/foreach}>
        </ul>
    </div>
    <{wap_pagers data=$pager}>
</div>

<script>
    function delete_product() {
        var url='<{link app=b2c ctl=wap_order act=dodelete arg0=$order.order_id}>';

        if(confirm("删除以后将不会再看到该订单，是否继续？")){
            $.post(url,function(re){
                location.reload();
            })
        }
    }
function receive(url){
    var xmlHttp;
    try{
        xmlHttp=new XMLHttpRequest();        
    }catch(e){
        try{
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }catch(e){
                return false;
            }
        }
    }
    xmlHttp.open('post',url);
    xmlHttp.onreadystatechange = function () {
        if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
            alert('已完成收货');
            location.reload();
        }
    }
        xmlHttp.send(null);
}

$('.del').bind('click',function(){
    if(confirm('确定删除该地址？'))
    $.post(this.href,function(re){
        var o = JSON.parse(re);
        if(o.success){
            new Dialog('#success',{'title':'删除成功'});
            setTimeout(function(){location.reload(true)},2000);
        }else{
            return alert(o.error);
        }
    });
    return false;
});
</script>
